import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClassificationItemVO, ClassificationItemForm, ClassificationItemQuery } from '@/api/fms/classificationItem/types';

/**
 * 查询财务项目列表
 * @param query
 * @returns {*}
 */

export const listClassificationItem = (query?: ClassificationItemQuery): AxiosPromise<ClassificationItemVO[]> => {
  return request({
    url: '/fms/classificationItem/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询财务项目详细
 * @param id
 */
export const getClassificationItem = (id: string | number): AxiosPromise<ClassificationItemVO> => {
  return request({
    url: '/fms/classificationItem/' + id,
    method: 'get'
  });
};

/**
 * 新增财务项目
 * @param data
 */
export const addClassificationItem = (data: ClassificationItemForm) => {
  return request({
    url: '/fms/classificationItem',
    method: 'post',
    data: data
  });
};

/**
 * 修改财务项目
 * @param data
 */
export const updateClassificationItem = (data: ClassificationItemForm) => {
  return request({
    url: '/fms/classificationItem',
    method: 'put',
    data: data
  });
};

/**
 * 删除财务项目
 * @param id
 */
export const delClassificationItem = (id: string | number | Array<string | number>) => {
  return request({
    url: '/fms/classificationItem/' + id,
    method: 'delete'
  });
};
